package restserviceplatform;

import org.eclipse.jface.action.*;
import org.eclipse.swt.*;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

   
    
    
    private IWorkbenchAction exitAction,newAction,closeAction,closeAllAction,
    aboutAction,copyAction,cutAction,pasteAction,deleteAction;

	public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
		super(configurer);
	}

	protected void makeActions(final IWorkbenchWindow window) {
		// Creates the actions and registers them.
		// Registering is needed to ensure that key bindings work.
		// The corresponding commands keybindings are defined in the plugin.xml
		// file.
		// Registering also provides automatic disposal of the actions when
		// the window is closed.

		exitAction = ActionFactory.QUIT.create(window);
		register(exitAction);
		
		newAction = ActionFactory.NEW.create(window);
		register(newAction);
		
		closeAction = ActionFactory.CLOSE.create(window);
		register(closeAction);
		
		closeAllAction = ActionFactory.CLOSE_ALL.create(window);
		register(closeAllAction);
		
		aboutAction = ActionFactory.ABOUT.create(window);
		register(aboutAction);
		
		copyAction = ActionFactory.COPY.create(window);
		register(copyAction);
		
		cutAction = ActionFactory.CUT.create(window);
		register(cutAction);
		
		pasteAction = ActionFactory.PASTE.create(window);
		register(pasteAction);
		
		deleteAction = ActionFactory.DELETE.create(window);
		register(deleteAction);
		
	}

	protected void fillMenuBar(IMenuManager menuBar) {
		MenuManager fileMenu = new MenuManager("&File",
				IWorkbenchActionConstants.M_FILE);
		menuBar.add(fileMenu);
		fileMenu.add(newAction);
		fileMenu.add(closeAction);
		fileMenu.add(closeAllAction);
		fileMenu.add(exitAction);
		
		MenuManager editMenu = new MenuManager("&Edit",
				IWorkbenchActionConstants.M_EDIT);
		menuBar.add(editMenu);
		editMenu.add(cutAction);
		editMenu.add(copyAction);
		editMenu.add(pasteAction);
		editMenu.add(deleteAction);
		
		MenuManager aboutMenu = new MenuManager("&About");
		menuBar.add(aboutMenu);
		aboutMenu.add(aboutAction);
	}
	
	protected void fillCoolBar(ICoolBarManager coolBar)
    {
    IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
    coolBar.add(new ToolBarContributionItem(toolbar));
    toolbar.add(newAction);
    toolbar.add(cutAction);
    toolbar.add(copyAction);
    toolbar.add(pasteAction);
    toolbar.add(deleteAction);
    toolbar.add(closeAction);
    toolbar.add(exitAction);
    
    }
    
}
